<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-10-03 14:17:19
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Models;

use App\Traits\AutoCodeTrait;
use App\Traits\CommonUserTrait;
use App\Traits\SoftDeletesTrait;


class MarketOfferPromotions extends BaseModel
    {
    use AutoCodeTrait;
    use SoftDeletesTrait;
    use CommonUserTrait;
    public $timestamps = true;
    public $table = "basedata_market_offer_promotions";
    protected $guarded = [];
    protected $casts = [];

    /**
     * 标识
     *
     * @var string
     */
    protected $ACSign = 'OFFER_PROMOTION';
    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'table_status');
            });
        }
    public function service()
        {
        return $this->belongsTo(Dic::class, "service_id", "key")->where(function ($q)
            {
            $q->where("code", 'Service');
            });
        }
    /**
     * 报价方案
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     * @author sunkaiyuan
     */
    public function roles()
        {
        return $this->hasMany(MarketOfferPromotionsRols::class, "promotions_id");
        }

    public function customer()
        {
        return $this->belongsTo(Company::class);
        }
    /**
     * 区域
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author sunkaiyuan
     */
    public function department()
        {
        return $this->belongsTo(Department::class);
        }
    }
